<template>
    <div style="height: 100%; width: 100%; position: relative" ref="maindev">
        <div class="pagetop">
            <table style="width: 100%; font-size: 12px" border="0">
                <tr>
                    <td>病历号</td>
                    <td>
                        <el-input size="small" style="width: 100%" placeholder="输入病历号" v-model="sel_patno"
                            @focus="Focus($event)"></el-input>
                    </td>
                    <td>病人姓名</td>
                    <td>
                        <el-input size="small" style="width: 100%" placeholder="输入病人姓名" v-model="sel_patname"
                            @focus="Focus($event)"></el-input>
                    </td>
                    <td>卡号</td>
                    <td>
                        <el-input size="small" style="width: 100%" placeholder="输入卡号" v-model="sel_patcardno"
                            @focus="Focus($event)"></el-input>
                    </td>
                    <td>身份证号</td>
                    <td>
                        <el-input size="small" style="width: 100%" placeholder="输入身份证号" v-model="sel_patidcardno"
                            @focus="Focus($event)"></el-input>
                    </td>
                    <td colspan="10">
                    </td>
                </tr>
                <tr>
                    <td>标本日期</td>
                    <td>
                        <el-date-picker v-model="sample_startdt" :able="false" type="date" placeholder="选择日期"
                            value-format="yyyy-MM-dd" style="width: 100%; min-width: 100px" :picker-options="pickerOptions"
                            :clearable="false" :key="startkey"> </el-date-picker>
                    </td>
                    <td align="center">至</td>
                    <td>
                        <el-date-picker v-model="sample_enddt" type="date" :able="false" placeholder="选择日期"
                            value-format="yyyy-MM-dd" style="width: 100%; min-width: 100px" :picker-options="pickerOptions"
                            :clearable="false" :key="endkey"> </el-date-picker>
                    </td>
                    <td>快速查找</td>
                    <td>
                        <el-input v-model="txtsearch" placeholder="报告单元|标本号|病人类别" style="width: 100%;"></el-input>
                    </td>
                    <td colspan="6"></td>
                    <td colspan="6" style="text-align:right;">
                        <el-button icon="el-icon-search" v-has="'PINQUERY'" type="primary" @click="BtnQuery()">查询(F8)
                        </el-button>
                        <el-button icon="el-icon-delete" @click="BtnClear">清除</el-button>
                    </td>
                </tr>
            </table>
        </div>
        <div class="pagecenter" :style="{ top: '70px' }">
            <el-tabs style="height: 100%" type="border-card" v-model="tab_showflag" @tab-click="tabclick_Event">
                <el-tab-pane label="报告单" name="tab_report">
                    <rm-layout-right splitcolor="#ffffff" :splitwidth="2" :fixsize="475" :minfixsize="200"
                        ref="layoutright">
                        <div style="height:100%; bottom: 40px">
                            <vxe-table :data.sync="report_data" :loading="report_Loading" :select-config="{ reserve: true }"
                                :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                                highlight-hover-column highlight-hover-row how-header-overflow ref="reportTable" resizable
                                show-overflow size="mini" :row-class-name="reportRowName" show-header-overflow
                                :optimization="{ animat: false }" @current-change="reportchange_Event"
                                :cell-class-name="reportCellName" @cell-dblclick="cellDblClickEvent" header-align="center">
                                <vxe-table-column field="alter_flag" sortable title="危" width="20" show-overflow
                                    align="center">
                                    <template v-slot="{ row, rowIndex, columnIndex }">
                                        <div :key="rowIndex + columnIndex"
                                            v-if="row.alter_flag == '1' || row.alter_flag == '2'">
                                            <font color="#000000">危</font>
                                        </div>
                                        <div :key="rowIndex + columnIndex" v-else></div>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column field="emer_flag" sortable title="急" width="20" show-overflow
                                    align="center">
                                    <template v-slot="{ row, rowIndex, columnIndex }">
                                        <div :key="rowIndex + columnIndex" v-if="row.emer_flag == '1'">
                                            <font color="red">急</font>
                                        </div>
                                        <div :key="rowIndex + columnIndex" v-else></div>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column field="redo_flag" sortable title="复" width="20" show-overflow
                                    align="center">
                                    <template v-slot="{ row, rowIndex, columnIndex }">
                                        <div :key="rowIndex + columnIndex"
                                            v-if="row.redo_flag == '2' || row.redo_flag == '3'">
                                            <font color="#000000">复</font>
                                        </div>
                                        <div :key="rowIndex + columnIndex" v-else></div>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column field="rechkflag" sortable title="审" width="20" show-overflow
                                    align="center">
                                    <template v-slot="{ row, rowIndex, columnIndex }">
                                        <div :key="rowIndex + columnIndex" v-if="row.rechkflag == '9'">
                                            <font color="#000000">审</font>
                                        </div>
                                        <div :key="rowIndex + columnIndex" v-else></div>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column align="center" field="rptunitname" sortable title="报告单元" width="130"
                                    show-overflow> </vxe-table-column>
                                <vxe-table-column align="center" field="sampledate" sortable title="标本日期" width="70"
                                    :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                                <vxe-table-column field="sampleno" align="center" sortable title="标本号" width="60"
                                    show-overflow :sort-width="20"></vxe-table-column>
                                <vxe-table-column field="pat_name" align="center" sortable title="病人姓名" width="60"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_no" sortable title="病人号" width="100" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="pat_sexname" align="center" sortable title="性别" width="35"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="rechk_dt" align="center" sortable title="审核时间" width="120"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="rechk_username" align="center" sortable title="审核医生" width="60"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="req_reason" sortable title="送检目的" width="400" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="pat_agestr" align="center" sortable title="年龄" width="40"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="specimen" sortable title="标本类型" width="90" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="req_bedno" align="center" sortable title="床号" width="50"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_typecodename" align="center" sortable title="病人类别" width="80"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="barcode" sortable title="条码号" width="100" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="req_deptnoname" sortable title="申请科室" width="150" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="req_wardnoname" sortable title="病人病区" width="120" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="charge_typenoname" align="center" sortable title="收费类别" width="90"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_diag" sortable title="临床诊断" width="250" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="req_dt" align="center" sortable title="申请时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="req_docnoname" align="center" sortable title="申请医生" width="70"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_cardno" sortable title="就诊卡号" width="110" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="inp_id" sortable title="就诊号" width="100" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="sampled_dt" align="center" sortable title="采样时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="recieve_dt" align="center" sortable title="接收时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="input_dt" align="center" sortable title="录入时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="test_info" sortable title="上机信息" width="120" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="test_dt" align="center" sortable title="上机时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="report_dt" align="center" sortable title="报告时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="report_username" align="center" sortable title="检验医生" width="70"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_id" sortable title="病人ID" width="130" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="report_comm" sortable title="报告单备注" width="150" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="lab_advice" sortable title="实验室意见" width="100" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="item_num" align="center" sortable title="项目数" width="50"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="instr_advice" sortable title="仪器辅助诊断" width="150"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="rechk2_dt" align="center" sortable title="二审时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="rechk2_user" align="center" sortable title="二审医生" width="70"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="lastprint_dt" align="center" sortable title="最后打印时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_birth" align="center" sortable title="病人生日" width="90"
                                    :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                                <vxe-table-column field="prereport_dt" align="center" sortable title="预计报告时间" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="reportid" sortable title="报告ID" width="160" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="hospcode" sortable title="送检医院" width="180" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="inp_date" align="center" sortable title="入院日期" width="140"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_phone" sortable title="联系电话" width="100" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="release_user" align="center" sortable title="发布人" width="70"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="is_changed" align="center" sortable title="是否修改" width="70"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="changed_afterreport" align="center" sortable title="打印、审核后修改"
                                    width="130" show-overflow></vxe-table-column>
                                <vxe-table-column field="unprint_flag" align="center" sortable title="禁止打印标志" width="100"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_diag_icd" sortable title="临床诊断标准码" width="160"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="pat_address" sortable title="病人地址" width="200" show-overflow>
                                </vxe-table-column>
                                <vxe-table-column field="pat_idcardno" align="center" sortable title="身份证/护照号" width="200"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="print_count" align="center" sortable title="打印次数" width="60"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="unprint_reason" sortable title="禁止打印原因" width="120"
                                    show-overflow></vxe-table-column>
                                <vxe-table-column field="txtinfo1" header-align="center" align="left" sortable
                                    title="文字描述1 / 骨髓 分析/特征" width="200" show-overflow></vxe-table-column>
                                <vxe-table-column field="txtinfo2" header-align="center" align="left" sortable
                                    title="文字描述2 / 骨髓 结论" width="200" show-overflow></vxe-table-column>
                            </vxe-table>
                        </div>
                        <template v-slot:fix>
                            <el-tabs style="height: 100%" type="border-card" v-model="tab_rshowflag"
                                @tab-click="tabclick_Event">
                                <el-tab-pane label="检验结果" name="tab_result">
                                    <div v-if="rpttype == '2'" class="right-inser">
                                        <div class="middle-tab-top">
                                            <vxe-table :data.sync="result_data" :loading="result_Loading"
                                                header-align="center" :select-config="{ reserve: true }"
                                                :sort-config="{ trigger: 'cell' }" border height="200px"
                                                highlight-current-row highlight-hover-column highlight-hover-row
                                                how-header-overflow ref="ymresulttable" resizable show-overflow size="mini"
                                                stripe show-header-overflow :optimization="{ animat: false }"
                                                @current-change="resultChange">
                                                <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="result_str" sortable title="检测结果" width="80"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="result1" sortable title="菌落计数" width="150"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="result4" sortable title="耐药机制" width="100"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="instrna" sortable title="检验仪器" width="100"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="interno" sortable title="通道号" width="100"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="alertflag" align="center" sortable title="危急标志"
                                                    width="60" show-overflow></vxe-table-column>
                                                <vxe-table-column field="result_flag" align="center" sortable title="结果标志"
                                                    width="60" show-overflow></vxe-table-column>
                                                <vxe-table-column field="redo_flag" align="center" sortable title="复查标志"
                                                    width="60" show-overflow></vxe-table-column>
                                                <vxe-table-column field="redo_result" sortable title="复查前结果" width="80"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="orig_result_num" sortable title="原始数值结果"
                                                    width="150" show-overflow></vxe-table-column>
                                                <vxe-table-column field="orig_result_str" sortable title="原始文本结果"
                                                    width="150" show-overflow></vxe-table-column>
                                                <vxe-table-column field="modify_flag" sortable title="修改标志" width="100"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="first_dt" align="center" sortable title="第一次填入时间"
                                                    width="120" show-overflow></vxe-table-column>
                                                <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间"
                                                    width="120" show-overflow></vxe-table-column>
                                                <vxe-table-column field="last_user" align="center" sortable title="最后修改人"
                                                    width="80" show-overflow></vxe-table-column>
                                                <vxe-table-column field="rptunitna" sortable title="报告单元" width="100"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="germflag" align="center" sortable title="细菌标志"
                                                    width="60" show-overflow></vxe-table-column>
                                                <vxe-table-column field="orig_result_flag" align="center" sortable
                                                    title="原始结果标志" width="60" show-overflow></vxe-table-column>
                                            </vxe-table>
                                            <div class="fixtotal">
                                                <div style="font-size: 12px; padding-top: 3px; background-color: #fff">
                                                    <span style="color: red; margin-left: 10px; float: right">合计: {{
                                                        result_amount }}</span>
                                                    <div style="clear: both"></div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="middle-tab-bottom">
                                            <vxe-table :data.sync="resusltmed_data" :select-config="{ reserve: true }"
                                                :sort-config="{ trigger: 'cell' }" border header-align="center"
                                                :height="ymresultheight" highlight-current-row highlight-hover-column
                                                highlight-hover-row how-header-overflow ref="ymresulttable2" resizable
                                                show-overflow size="mini" stripe show-header-overflow
                                                :optimization="{ animat: false }">
                                                <vxe-table-column field="medcodename" sortable title="抗生素" width="220"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="medresult" sortable title="药敏结果"
                                                    header-align="center" align="center" width="60" show-overflow>
                                                    <template v-slot="{ row }">
                                                        <div :style="{
                                                            background: row.cp_resultbackgroundcolor,
                                                            color: row.cp_resultcolor,
                                                        }" style="padding: 0px 10px">
                                                            {{ row.medresult }}
                                                        </div>
                                                    </template>
                                                </vxe-table-column>
                                                <vxe-table-column field="rad" sortable title="Rad" width="60"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="mic" sortable title="Mic" width="60"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="result_flag" align="center" sortable title="标志"
                                                    width="60" show-overflow></vxe-table-column>
                                                <vxe-table-column field="result6" sortable title="参考范围" width="120"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="expertresult" sortable title="专家值" width="100"
                                                    show-overflow></vxe-table-column>
                                                <vxe-table-column field="medgroup" align="center" sortable title="分组"
                                                    width="80" show-overflow></vxe-table-column>
                                            </vxe-table>
                                            <div class="fixtotal">
                                                <div style="font-size: 12px; padding-top: 3px; background-color: #fff">
                                                    <span style="color: red; margin-left: 10px; float: right">合计: {{
                                                        ymresultitem_amount }}</span>
                                                    <div style="clear: both"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div v-if="rpttype == '1'" class="right-inser">
                                        <vxe-table :data.sync="result_data" :loading="result_Loading" header-align="center"
                                            :select-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }" border
                                            :height="resultheight" highlight-current-row highlight-hover-column
                                            highlight-hover-row how-header-overflow ref="resulttable" resizable
                                            show-overflow size="mini" stripe show-header-overflow
                                            :optimization="{ animat: false }">
                                            <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220"
                                                show-overflow>
                                                <template v-slot="{ row }">
                                                    <div v-if="row.alertflag == '1'"
                                                        style="background: red; padding: 0px 10px">
                                                        {{ row.rpt_itemname }}
                                                    </div>
                                                    <div v-else style="padding: 0px 10px">
                                                        {{ row.rpt_itemname }}
                                                    </div>
                                                </template>
                                            </vxe-table-column>
                                            <vxe-table-column field="result_str" sortable title="检测结果" width="80"
                                                show-overflow>
                                                <template v-slot="{ row }">
                                                    <div :style="{
                                                        background: row.cp_resultbackgroundcolor,
                                                        color: row.cp_resultcolor,
                                                    }" style="padding: 0px 10px">
                                                        {{ row.result_str }}
                                                    </div>
                                                </template>
                                            </vxe-table-column>
                                            <vxe-table-column field="result_unit" sortable title="单位" width="70"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="result_ref" sortable title="参考值" width="100"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="result1" sortable title="OD值" width="70px"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="result2" sortable title="SCO值" width="70px"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="result3" sortable title="Cutoff值" width="70px"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="result_txt" sortable title="大文本结果" width="130"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="instrname" sortable title="检验仪器" width="100"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="interno" sortable title="通道号" width="100"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="alertflag" align="center" sortable title="危急标志"
                                                width="60" show-overflow></vxe-table-column>
                                            <vxe-table-column field="result_flag" align="center" sortable title="结果标志"
                                                width="60" show-overflow></vxe-table-column>
                                            <vxe-table-column field="redo_flag" align="center" sortable title="复查标志"
                                                width="60" show-overflow></vxe-table-column>
                                            <vxe-table-column field="redo_result" sortable title="复查前结果" width="120"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="120"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="120"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="modify_flag" align="center" sortable title="修改标志"
                                                width="60" show-overflow></vxe-table-column>
                                            <vxe-table-column field="first_dt" align="center" ortable title="第一次填入时间"
                                                width="120" show-overflow></vxe-table-column>
                                            <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间"
                                                width="120" show-overflow></vxe-table-column>
                                            <vxe-table-column field="last_user" align="center" sortable title="最后修改人"
                                                width="80" show-overflow></vxe-table-column>
                                            <vxe-table-column field="rptunitid" sortable title="报告单元ID" width="80"
                                                show-overflow></vxe-table-column>
                                            <vxe-table-column field="germflag" align="center" sortable title="细菌标志"
                                                width="60" show-overflow></vxe-table-column>
                                            <vxe-table-column field="orig_result_flag" align="center" sortable
                                                title="原始结果标志" width="160" show-overflow></vxe-table-column>
                                        </vxe-table>
                                        <div class="fixtotal">
                                            <div style="font-size: 12px; padding-top: 3px; background-color: #fff">
                                                <span style="color: red; margin-left: 10px; float: right">合计: {{
                                                    result_amount }}</span>
                                                <div style="clear: both"></div>
                                            </div>
                                        </div>
                                    </div>
                                    <div v-if="rpttype == '3'" class="right-inser">
                                        <div style="height: calc(100% - 5px); width: calc(100% - 5px)">
                                            <iframe :src="image" style="width: 100%; height: 100%"></iframe>
                                        </div>
                                    </div>
                                </el-tab-pane>
                            </el-tabs>
                        </template>
                    </rm-layout-right>
                </el-tab-pane>
            </el-tabs>
        </div>
    </div>
</template>

<script>
import XE from "xe-utils"; //引入工具类
export default {
    name: "LIS423",
    data() {
        const _that = this;
        return {
            report_Loading: false,
            txtsearch: "",
            allreport_data: [],
            tab_showflag: "tab_report",
            tab_rshowflag: "tab_result",
            sel_patno: "",
            sel_patname: "",
            sel_patcardno: "",
            sel_patidcardno: "",
            sample_startdt: this.$pub.InitDateTime2(3).datefrom,
            sample_enddt: this.$pub.InitDateTime2(0).dateto,
            show_right: true,
            rpttype: "1",
            result_data: [],
            result_Loading: false,
            resusltmed_data: [],
            allresusltmed_data: [],
            //master_data: [],
            //master_Loading: false,
            resultheight: "auto",
            ymresultheight: "auto",
            startkey: 0,
            endkey: 0,
            //mstr_amount: 0,
            result_amount: 0,
            ymresultitem_amount: 0,
            pickerOptions: {
                shortcuts: [
                    {
                        text: "今天",
                        onClick(picker) {
                            picker.$emit("pick", new Date());
                            _that.sample_startdt = new Date();
                            _that.sample_enddt = new Date();
                        },
                    },
                ],
            },
            image: "",
        };
    },
    created() {
        this.BtnClear();
    },
    mounted() {
        document.onkeydown = function (e) {
            let key = window.event.keyCode;
            switch (key) {
                case 119: //查询F8
                    this.BtnQuery();
                    break;
            }
        };
    },
    computed: {
        report_data() {
            let samplestart = this.sample_startdt;
            let sampleend = this.sample_enddt;
            let filterName = this.txtsearch.trim();
            let retdata = this.allreport_data.filter((item) => {
                return this.CompareDate(item.sampledate, samplestart) && this.CompareDate(sampleend, item.sampledate);
            });
            if (filterName) {
                retdata = retdata.filter((item) => {
                    return (item.rptunitname ? item.rptunitname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.sampleno ? item.sampleno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false) || (item.pat_typecodename ? item.pat_typecodename.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                });
            }
            return retdata;
        },
    },
    methods: {
        CompareDate(day1, day2) {
            var oDate1 = new Date(day1);
            var oDate2 = new Date(day2);
            //精确到天
            return oDate1.toLocaleDateString() >= oDate2.toLocaleDateString();
        },
        QueryImagePDF(filehex) {
            if (filehex) {
                this.$tool
                    .request({
                        url: "/ucent/downloadfile",
                        method: "post",
                        responseType: "blob",
                        data: {
                            prgno: "LIS423",
                            filehex: filehex,
                        },
                    })
                    .then((res) => {
                        let blob = new Blob([res], {
                            type: "application/pdf",
                        });
                        let objectUrl = window.URL.createObjectURL(blob);
                        this.image = objectUrl;
                    });
            } else {
                this.image = "";
            }
        },
        BtnQuery() {
            this.report_Loading = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS423",
                    method: "post",
                    data: {
                        action: "queryreport",
                        pat_no: this.sel_patno,
                        pat_name: this.sel_patname,
                        pat_cardno: this.sel_patcardno,
                        pat_idcardno: this.sel_patidcardno,
                        startdate: this.sample_startdt,
                        endstart: this.sample_enddt,
                    },
                })
                .then((res) => {
                    this.report_Loading = false;
                    // 添加后台日志查询返回
                    if (res.flag == 1) {
                        this.allreport_data = res.reports;
                        this.result_data = [];
                        if (this.report_data.length > 0) {
                            this.$refs.reportTable.setCurrentRow(this.report_data[0]);
                            this.queryResult(this.report_data[0]);
                        }
                    } else {
                        this.$message.error(res.msg);
                    }
                })
                .catch(() => { });
        },
        reportchange_Event({ row, rowIndex, column, columnIndex }, event) {
            this.tab_rshowflag = "tab_result";
            this.queryResult(row);
        },
        resultChange({ row, rowIndex, column, columnIndex }, event) {
            if (this.allresusltmed_data.length > 0) {
                this.resusltmed_data = this.allresusltmed_data.filter(item => {
                    return item.rpt_itemcode == row.rpt_itemcode;
                });
            }
        },
        queryResult(row) {
            this.result_Loading = true;
            this.resusltmed_data = [];
            if (row.reporttype == "20") {
                this.rpttype = "2";//细菌报告
            } else if (row.reporttype == "50") {
                this.rpttype = "3";//pdf导出报告
            } else {
                this.rpttype = "1";//普通报告
            }
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS423",
                    method: "post",
                    data: {
                        action: "queryresult",
                        reportid: row.reportid,
                        rpttype: this.rpttype,
                    },
                })
                .then((res) => {
                    this.result_Loading = false;
                    if (this.rpttype == "2") {
                        this.result_data = res.result;
                        this.result_amount = this.result_data.length;
                        if (this.result_amount > 0) {
                            setTimeout(() => {
                                this.$refs.ymresulttable.setCurrentRow(this.result_data[0]);
                                this.allresusltmed_data = res.resultmed;
                                if (this.allresusltmed_data.length > 0) {
                                    this.resusltmed_data = this.allresusltmed_data.filter(item => {
                                        return item.rpt_itemcode == this.result_data[0].rpt_itemcode;
                                    });
                                    this.ymresultitem_amount = this.resusltmed_data.length;
                                }
                            }, 80);
                        }
                    } else if (this.rpttype == "3") {
                        this.image = "";
                        this.QueryImagePDF(row.filehex);
                    } else {
                        this.result_data = res.result;
                        this.result_amount = this.result_data.length;
                    }
                })
                .catch(() => {
                    this.result_Loading = false;
                });
        },
        tabclick_Event(tab, event) {
            if (tab.label == "报告单") {
                this.show_right = true;
            }
            //暂时不考虑查询申请单
        },
        BtnClear() {
            this.rpttype = "1";
            this.image = "";
            this.report_Loading = false;
            this.allreport_data = [];
            this.result_data = [];
            this.resusltmed_data = [];
            this.sel_patno = "";
            this.sel_patname = "";
            this.sel_patcardno = "";
            this.sel_patidcardno = "";
            this.tab_showflag = "tab_report";
            this.sample_startdt = this.$pub.InitDateTime2(3).datefrom;
            this.sample_enddt = this.$pub.InitDateTime2(0).dateto,
                this.show_right = true;
        },
        reportRowName({ row, rowIndex }) {
            if (row.rechk_dt != "" && row.rechk_dt != " " && row.rechk_dt != null) {
                if (XE.toNumber(row.print_count) > 0) {
                    return "rm-gray"; //审核过打印的
                } else {
                    return "colrow"; //没打印的
                }
            }
        },
        reportCellName({ row, rowIndex, column, columnIndex }) {
            if (column.property == "alter_flag") {
                if (row.alter_flag == "1" || row.alter_flag == "2") {
                    return "colred";
                }
            } else if (column.property == "redo_flag") {
                if (row.redo_flag == "2" || row.redo_flag == "3") {
                    return "colgreen";
                }
            } else if (column.property == "rptunitname" || column.property == "sampleno" || column.property == "pat_typecodename") {
                // 添加链接查询颜色
                return "col-blue";
            } else if (column.property == "unprint_reason") {
                return "col-red";
            }
        },
        //双击链接查询
        cellDblClickEvent({ row, column }) {
            if (column.property == "pat_no") {
                this.sel_patno = row.pat_no;
                this.BtnQuery();
            } else if (column.property == "pat_name") {
                this.sel_patname = row.pat_name;
                this.BtnQuery();
            } else if (column.property == "pat_idcardno" && row.pat_idcardnoen && row.pat_idcardnoen.length > 0) {
                this.Dec(row.pat_idcardnoen, "身份证/护照号");
            } else if (column.property == "pat_phone" && row.pat_phoneen && row.pat_phoneen.length > 0) {
                this.Dec(row.pat_phoneen, "电话");
            }
        },
        async Dec(ciphertext, name) {
            try {
                const res = await this.$tool.request({
                    url: "ucent/ddl",
                    method: "post",
                    data: {
                        action: "sm4decrypt",
                        ciphertext: ciphertext,
                    },
                });
                if (res) {
                    this.$alert(res, name, {
                        confirmButtonText: "确定",
                    });
                }
            } catch (e) {
                this.$message.warning(e);
            }
        },
        Focus(event) {
            event.currentTarget.select();
        },
    }
};


</script>

<style scoped>
::v-deep .el-checkbox__inner::after {
    border: 2px solid #000000 !important;
    box-sizing: content-box;
    content: "";
    border-left: 0 !important;
    border-top: 0 !important;
    height: 7px;
    left: 4px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg) scaleY(0);
    width: 3px;
    transition: transform 0.15s ease-in 0.05s;
    transform-origin: center;
}

::v-deep .el-checkbox__input.is-disabled+span.el-checkbox__label {
    color: #000000;
    cursor: not-allowed;
}

::v-deep .el-checkbox__label {
    display: inline-block;
    padding-left: 5px;
}

::v-deep .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner+.el-input.is-disabled .el-input__inner {
    background-color: #ffffff !important;
}

::v-deep .el-input--suffix .el-input__inner {
    padding-right: 5px;
}

.middle-tab-bottom {
    position: absolute;
    top: 0px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}

.pagetop {
    left: 0;
    right: 0;
    height: 70px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
    position: absolute;
    z-index: 99;
    overflow-x: auto;
    white-space: nowrap;
}

.pagecenter {
    position: absolute;
    top: 125px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}

.pagebottom {
    position: absolute;
    width: 100%;
    left: 0;
    margin-top: 4px;
    height: 36px;
    bottom: 0px;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
}

.right-inser {
    position: absolute;
    top: 0;
    bottom: 0px;
    overflow: auto;
    width: 100%;
    right: 0px;
}

table tr td:nth-child(odd) {
    text-align: right;
    white-space: nowrap;
}

table tr td:nth-child(even) {
    text-align: left;
}

table tr td:nth-child(1) {
    width: 80px;
}

table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 5px;
}

.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409eff;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.avatar {
    width: 178px;
    height: 178px;
    display: block;
}

.avatar-uploader-icon1 {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 50px;
    line-height: 50px;
    text-align: center;
}

.avatar1 {
    width: 178px;
    height: 50px;
    display: block;
}

.middle-tab-top {
    position: absolute;
    top: 0px;
    width: 100%;
    height: 200px;
}

.middle-bottom {
    position: absolute;
    top: 37px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}

.middle-tab-bottom {
    position: absolute;
    top: 203px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}

.poppagetop {
    width: 100%;
    height: 24px;
    -webkit-box-pack: left;
    -webkit-box-align: center;
    position: absolute;
    /* border: 1px solid #ccc; */
    z-index: 999;
}

.poppagecenter {
    position: absolute;
    overflow: auto;
    top: 27px;
    width: 100%;
    height: 450px;
    left: 0;
}

::v-deep .el-select-dropdown__wrap {
    max-width: 400px;
}

::v-deep .vxe-table .vxe-body--row.row--hover td {
    background-color: #d7f1fd;
    vertical-align: top !important;
}

::v-deep .vxe-table.size--mini .vxe-body--column,
.vxe-table.size--mini .vxe-footer--column,
.vxe-table.size--mini .vxe-header--column {
    padding: 1px 0;
    vertical-align: top !important;
}

::v-deep .vxe-table .vxe-sort-wrapper {
    padding: 0 0px;
}

::v-deep .colred {
    background-color: red !important;
}

::v-deep .colgreen {
    background-color: #00ff00 !important;
}

::v-deep .colrow {
    background-color: #c0ffc0;
}

::v-deep .el-input.is-disabled .el-input__inner {
    color: #606266;
    cursor: default;
}

::v-deep .vxe-table .vxe-body--column.col-blue {
    color: blue;
}

::v-deep .vxe-table .vxe-body--column.col-red {
    color: red;
}

.fixtotal {
    overflow: hidden;
    position: absolute;
    left: 0px;
    bottom: 3%;
    z-index: 1;
    width: 100%;
}</style>
